package apps.MyJMRI;
import apps.Apps;
import apps.MyJMRI.RemoteFrame;

import java.awt.Dimension;
import javax.swing.*;

import jmri.jmrit.XmlFile;
import jmri.jmrit.throttle.LoadXmlThrottleAction;
import jmri.util.JmriJFrame;

public class MyJMRI extends Apps {
	private static final long serialVersionUID=1;
	boolean onMac = (System.getProperty("mrj.version") != null);

	MyJMRI(JFrame p) {
		super(p);

		try
		{
			String regs = XmlFile.prefsDir()+"/RegAutoLoad";
			java.io.File fregs = new java.io.File(regs) ;        	
			LoadXmlThrottleAction regsLoader = new LoadXmlThrottleAction("autoLoader") ;
			regsLoader.loadThrottles (fregs);
		}
		catch (Exception e)
		{
			System.out.println("Error loading default throttles (RegAutoLoad)");   	
		}
	}

	protected String line1() {
		return "MyJMRI 0.1" ;
	}

	// Main entry point    
	public static void main(String args[]) {

		// show splash screen early
		splash(true);

		initLog4J();
		log.info(apps.Apps.startupInfo("MyJMRI"));

		setConfigFilename("JmriDemoConfig2.xml", args);
		JmriJFrame f = new JmriJFrame("MyJMRI");   
		Apps apps = new MyJMRI(f);
		createFrame( apps, f);

		JmriJFrame f2 = new RemoteFrame("Remote control frame");
		f2.pack();
		f2.setSize(900, 700);        
		Dimension screen = f2.getToolkit().getScreenSize();
		Dimension size = f2.getSize();
		f2.setLocation((screen.width-size.width)/2,(screen.height-size.height)/2);
		f2.setVisible(true);

		log.debug("main initialization done");
		splash(false);
	}

	static org.apache.log4j.Category log = org.apache.log4j.Category.getInstance(MyJMRI.class.getName());
}


